The primary purpose of classes that implement indexed access operators is that of element access, like this is the case for arrays, lists, maps, or
sets. When a class implements indexed access operators, they should be used as operators instead of calling them as functions, because this is the
intention of the designer of the API.
What is the potential impact?
Readability and Understanding
This change makes it easier to understand what a function does, because the semantics of indexed access operators is evident to the reader, while
for a function call, the reader would need to know what the called function does.
Java interop
The issue is also raised when Java API is used as a Kotlin compiler treats all get(.)
methods as possible index access operators. Use
CompletableFuture[timeout, unit]
instead of CompletableFuture.get(timeout, unit)
when accessing Java’s
CompletableFuture
.